package com.dyna.demo.dictConvert;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyna.demo.dictConvert.domain.UserDemo;
import com.dyna.demo.dictConvert.mapper.DictConvertMapper;
import com.dyna.domain.resp.R;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * demo模块/字典类型转换
 * @author zhoucaiwang
 * @date 2023/10/12
 */

@Validated
@RestController
@AllArgsConstructor
@RequestMapping(value = "/dict")
public class DictConvertController {

    private DictConvertService dictConvertService;

    @RequestMapping(value = "dictConvert")
    public R<List<UserDemo>> dictConvert() {
        return R.data(dictConvertService.dictConvert());
    }

}



interface DictConvertService extends IService<UserDemo> {

    /**
     * 字典转换
     * @return List<User>
     */
    List<UserDemo> dictConvert();

}

@Service
class DictConvertServiceImpl extends ServiceImpl<DictConvertMapper, UserDemo> implements DictConvertService {

    @Resource
    private DictConvertMapper dictConvertMapper;

    @Override
    public List<UserDemo> dictConvert() {
        Page<UserDemo> demoPage = new Page<>(1,10);
        QueryWrapper<UserDemo> queryWrapper = new QueryWrapper<>();
        Page<UserDemo> page = dictConvertMapper.selectPage(demoPage, queryWrapper);
        return page.getRecords();
    }

}

